package test_package;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

/**
 * Created by iryna on 3/29/14.
 */
public class HomePage {
    //can be any Webdriver not only firefox
    private WebDriver driver;


    public HomePage(FirefoxDriver driver){
        this.driver = driver;

    }

    public ResultPage search(String text){
        driver.findElement(By.name("text")).sendKeys(text);
        driver.findElement(By.xpath("/html/body/header/div[2]/div/div/div/div[2]/form/div/span/button")).click();

        return new ResultPage(driver);

    }

    public  NavigationPage navigateTo(int menu_page_number){



        switch (menu_page_number){
            case 6:
                driver.findElement(By.xpath("/html/body/header/div/div/div/ul/li[5]/a")).click();
                break;
            case 5:
                driver.findElement(By.xpath("/html/body/header/div/div/div/ul/li[4]/a")).click();
                break;
            case 4:
                driver.findElement(By.xpath("/html/body/header/div/div/div/ul/li[3]/a")).click();
                break;
            case 3:
                driver.findElement(By.xpath("/html/body/header/div/div/div/ul/li[2]/a")).click();
                break;
            case 2:
                driver.findElement(By.xpath("/html/body/header/div/div/div/ul/li/a")).click();
                break;
            case 1:
                driver.findElement(By.xpath("/html/body/header/div/div/div/div/a")).click();
                break;



            default:
                driver.findElement(By.xpath("/html/body/header/div[2]/div/div/div/div/img")).click();
                break;
        }




        return new  NavigationPage(driver);

    }



    public RegistrationPage signIn(){

        driver.findElement(By.xpath("/html/body/header/div/div/div/div[3]/div[2]/div/a")).click();
        driver.findElement(By.linkText("Зарегистрироваться")).click();

        return new RegistrationPage(driver);

    }




}
